home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / ixemul / include / rpc / auth.h < prev    next >
C/C++ Source or Header  |  1997-10-28  |  5KB  |  185 lines

  1. /*    $NetBSD: auth.h,v 1.7 1995/04/29 05:27:55 cgd Exp $    */
  2.  
  3. /*
  4.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  5.  * unrestricted use provided that this legend is included on all tape
  6.  * media and as a part of the software program in whole or part.  Users
  7.  * may copy or modify Sun RPC without charge, but are not authorized
  8.  * to license or distribute it to anyone else except as part of a product or
  9.  * program developed by the user.
  10.  * 
  11.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  12.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  13.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  14.  * 
  15.  * Sun RPC is provided with no support and without any obligation on the
  16.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  17.  * modification or enhancement.
  18.  * 
  19.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  20.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  21.  * OR ANY PART THEREOF.
  22.  * 
  23.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  24.  * or profits or other special, indirect and consequential damages, even if
  25.  * Sun has been advised of the possibility of such damages.
  26.  * 
  27.  * Sun Microsystems, Inc.
  28.  * 2550 Garcia Avenue
  29.  * Mountain View, California  94043
  30.  *
  31.  *    from: @(#)auth.h 1.17 88/02/08 SMI
  32.  *    @(#)auth.h    2.3 88/08/07 4.0 RPCSRC
  33.  */
  34.  
  35. /*
  36.  * auth.h, Authentication interface.
  37.  *
  38.  * Copyright (C) 1984, Sun Microsystems, Inc.
  39.  *
  40.  * The data structures are completely opaque to the client.  The client
  41.  * is required to pass a AUTH * to routines that create rpc
  42.  * "sessions".
  43.  */
  44.  
  45. #ifndef _RPC_AUTH_H
  46. #define _RPC_AUTH_H
  47. #include <sys/cdefs.h>
  48.  
  49. #define MAX_AUTH_BYTES    400
  50. #define MAXNETNAMELEN    255    /* maximum length of network user's name */
  51.  
  52. /*
  53.  * Status returned from authentication check
  54.  */
  55. enum auth_stat {
  56.     AUTH_OK=0,
  57.     /*
  58.      * failed at remote end
  59.      */
  60.     AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  61.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  62.     AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  63.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  64.     AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  65.     /*
  66.      * failed locally
  67.     */
  68.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  69.     AUTH_FAILED=7            /* some unknown reason */
  70. };
  71.  
  72. typedef u_int32_t u_int32;    /* 32-bit unsigned integers */
  73.  
  74. union des_block {
  75.     struct {
  76.         u_int32 high;
  77.         u_int32 low;
  78.     } key;
  79.     char c[8];
  80. };
  81. typedef union des_block des_block;
  82. __BEGIN_DECLS
  83. extern bool_t xdr_des_block __P((XDR *, des_block *));
  84. __END_DECLS
  85.  
  86. /*
  87.  * Authentication info.  Opaque to client.
  88.  */
  89. struct opaque_auth {
  90.     enum_t    oa_flavor;        /* flavor of auth */
  91.     caddr_t    oa_base;        /* address of more auth stuff */
  92.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  93. };
  94.  
  95.  
  96. /*
  97.  * Auth handle, interface to client side authenticators.
  98.  */
  99. typedef struct __rpc_auth {
  100.     struct    opaque_auth    ah_cred;
  101.     struct    opaque_auth    ah_verf;
  102.     union    des_block    ah_key;
  103.     struct auth_ops {
  104.         void    (*ah_nextverf) __P((struct __rpc_auth *));
  105.         /* nextverf & serialize */
  106.         int    (*ah_marshal) __P((struct __rpc_auth *, XDR *));
  107.         /* validate varifier */
  108.         int    (*ah_validate) __P((struct __rpc_auth *,
  109.                 struct opaque_auth *));
  110.         /* refresh credentials */
  111.         int    (*ah_refresh) __P((struct __rpc_auth *));
  112.         /* destroy this structure */
  113.         void    (*ah_destroy) __P((struct __rpc_auth *));
  114.     } *ah_ops;
  115.     caddr_t ah_private;
  116. } AUTH;
  117.  
  118.  
  119. /*
  120.  * Authentication ops.
  121.  * The ops and the auth handle provide the interface to the authenticators.
  122.  *
  123.  * AUTH    *auth;
  124.  * XDR    *xdrs;
  125.  * struct opaque_auth verf;
  126.  */
  127. #define AUTH_NEXTVERF(auth)        \
  128.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  129. #define auth_nextverf(auth)        \
  130.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  131.  
  132. #define AUTH_MARSHALL(auth, xdrs)    \
  133.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  134. #define auth_marshall(auth, xdrs)    \
  135.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  136.  
  137. #define AUTH_VALIDATE(auth, verfp)    \
  138.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  139. #define auth_validate(auth, verfp)    \
  140.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  141.  
  142. #define AUTH_REFRESH(auth)        \
  143.         ((*((auth)->ah_ops->ah_refresh))(auth))
  144. #define auth_refresh(auth)        \
  145.         ((*((auth)->ah_ops->ah_refresh))(auth))
  146.  
  147. #define AUTH_DESTROY(auth)        \
  148.         ((*((auth)->ah_ops->ah_destroy))(auth))
  149. #define auth_destroy(auth)        \
  150.         ((*((auth)->ah_ops->ah_destroy))(auth))
  151.  
  152.  
  153. extern struct opaque_auth _null_auth;
  154.  
  155.  
  156. /*
  157.  * These are the various implementations of client side authenticators.
  158.  */
  159.  
  160. /*
  161.  * Unix style authentication
  162.  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  163.  *    char *machname;
  164.  *    int uid;
  165.  *    int gid;
  166.  *    int len;
  167.  *    int *aup_gids;
  168.  */
  169. __BEGIN_DECLS
  170. struct sockaddr_in;
  171. extern AUTH *authunix_create        __P((char *, int, int, int, int *));
  172. extern AUTH *authunix_create_default    __P((void));
  173. extern AUTH *authnone_create        __P((void));
  174. extern AUTH *authdes_create        __P((char *, u_int,
  175.                         struct sockaddr_in *, des_block *));
  176. __END_DECLS
  177.  
  178. #define AUTH_NONE    0        /* no authentication */
  179. #define    AUTH_NULL    0        /* backward compatibility */
  180. #define    AUTH_UNIX    1        /* unix style (uid, gids) */
  181. #define    AUTH_SHORT    2        /* short hand unix style */
  182. #define AUTH_DES    3        /* des style (encrypted timestamps) */
  183.  
  184. #endif /* !_RPC_AUTH_H */
  185.